{template header}
<script language="javascript" type="text/javascript" src="js/command.js"></script>
<script language="javascript" type="text/javascript">	

J(function(){
	bopuruiObj.category = {
		Symbol: '￥',
		init: function(){
		
			_this = this;
			
			J('input[name=pCount]').bind('keypress', function(){_this.strMacth(J(this));}).bind('blur', function(){_this.strMacth(J(this));}).bind('keyup', function(){_this.strMacth(J(this));});

			J('#clearShopping').bind('click', function(){
				if(confirm('您确定要清空购物车吗?')){
					var cartId = '';
					J('input[name=cartId]').each(function(){cartId = cartId + J(this).val() + '-';});
					J.ajax({
						url: 'cart.htm?action=clear&cartId='+cartId,
						cache: false,
						dataType: 'json',
						success: function(data){
							if(data['state']==1) {
								J('.t_nav').remove();
								J('.td_b_on').remove();
								J('.t_maincla1').html('<table width="100%" border="0" cellpadding="0" cellspacing="0" id="shoppingItem"><tr class="td_b_on"><td colspan="8" style="width: 13%; line-height: 15px; color: #ff0000; padding-left: 8px;">你的购物车中还没有信息!</td></tr></table>');
							}
						}
					});
				}
			});
			
			J('a[id=del]').bind('click', function(){
				if(confirm('您确定要删除吗?')){
					var productId = J(this).attr('productId');
					J.ajax({
						url: 'cart.htm?action=del&productId='+productId,
						cache: false,
						dataType: 'json',
						success: function(data){
							if(data['state']==1) {
								J('#J_Total').html(_this.Symbol+data['pr']['totalPrice']);
								J('#cartCount').html(data['pr']['cartCount']);
								J('#tr_'+productId).remove();
							}
						}
					});
				}
			});
			
			J('a[id=add]').bind('click', function(){
				var productId = J(this).attr('productId');	
				var price = J('#pCount_'+productId).val();
				var key = J(this).attr('key');
				J('#pCount_'+productId).val(parseInt(price)+1);					
				_this.getAjax('add', productId, key);
			});
			
			J('a[id=less]').bind('click', function(){
				var productId = J(this).attr('productId');	
				var price = J('#pCount_'+productId).val();
				var key = J(this).attr('key');
		
				if(parseInt(price) > 1) {
					J('#pCount_'+J(this).attr('productId')).val(parseInt(price)-1);
					_this.getAjax('less', productId, key);
				}
			});
			
			bopuruiObj.command.mtabletr();
		},
		getAjax: function(type, productId, key, value){
			_this = this;
			J.ajax({
				url: 'cart.htm?action='+type+'&productId='+productId+'&value='+value,
				cache: false,
				dataType:'json',
				success: function(data){
					if(data['state']==1) {
						J('#J_Total').html(_this.Symbol+data['pr']['totalPrice']);
						J('#total_'+productId).html(_this.Symbol+data['pr']['shopCartArr'][key]['totalPrice']);
						J('#offer_'+productId).html(_this.Symbol+data['pr']['shopCartArr'][key]['offerPrice']);
						J('#cartCount').html(data['pr']['cartCount']);
					}
				}
			});
		},
		strMacth: function(__this){
			if(/[^\d]/g.test(__this.val())){
				__this.val(__this.val().replace(/[^\d]/g,''));
			}
			var productSum = __this.val();
			if(productSum < 1){
				alert('数量输入错误！');
			} else {
				var productId = __this.attr('productId');	
				var key = __this.attr('key');
				this.getAjax('update', productId, key, productSum);
			}
		}
	}

	bopuruiObj.category.init();
});

</script>


<div class="maininfo">
	<div class="lattice x1" style="padding-left: 0;">
		{template userlogin}
	</div>

	<div class="lattice x4" style="padding-right: 0;">
		<div class="table">
			<form id="Form1" method="post" action="cart-consignee.htm">
			<div class="boxcla1">
				<div class="hd">
					<div class="r">
						<div class="m"></div>
					</div>
				</div>

				<div class="bd">
					<div class="t_headcla1">
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
							<thead>
								<tr>
									<td style="width: 13%; padding-left: 5px;">订货号</td>
									<td align="center" style="width: 23%; text-align:center; padding-right: 5px;">产品说明</td>
									<td align="center" style="width: 13%; text-align:center; padding-right: 5px;">本店价格<span id="ctl00_ContentPlaceHolder1_pricePage"></span></td>
									<td id="ctl00_ContentPlaceHolder1_quantity" style="width: 13%; text-align: center;">会员价格</td>
									<td id="ctl00_ContentPlaceHolder1_quantity" style="width: 12%; text-align: center;">小计</td>
									<td id="ctl00_ContentPlaceHolder1_quantity" style="width: 8%; text-align: center;">优惠</td>
									<td id="ctl00_ContentPlaceHolder1_quantity" style="width: 12%; text-align: center;">数量</td>
									<td id="ctl00_ContentPlaceHolder1_quantity" style="width: 6%; text-align: center;">&nbsp;</td>
								</tr>
							</thead>
						</table>
					</div>
				</div>

				<div class="ft">
					<div class="r">
					<div class="m"></div>
					</div>
				</div>

			</div>

			<div class="t_maincla1">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" id="shoppingItem" class="table1">
					<tbody>
						<!--{loop $pArr[shopCartArr] $key $list}-->
						<tr id="tr_$list[productId]" class="td_b_on">
							<td style="width: 13%; line-height: 15px; color: #333; padding-left: 8px;"><input type="hidden" name="cartId" value="{$list[cartId]}" />$list[productNo]</td>
							<td nowrap="nowrap" style="width: 23%; text-align: center; color:#000000;" class="high">$list[content]</td>
							<td nowrap="nowrap" style="width: 13%; text-align: center; color:#000000;" class="high">￥$list[ourPrice]</td>
							<td align="center" style="width: 13%;">￥$list[userPrice]</td>
							<td align="center" style="width: 12%; color:#FE6500; font-weight:bold" id="total_$list[productId]">￥$list[totalPrice]</td>
							<td align="center" style="width: 8%; font-weight:bold" id="offer_$list[productId]">￥$list[offerPrice]</td>
							<td align="center" style="width: 12%; padding-left:12px;">
							<a id="less" key=$key productId="$list[productId]" href="#1" style="display:block; margin-top:5px; float:left;width:10px; height:10px; line-height:10px; border:1px solid #DBDBDB">-</a>
							<input key=$key productId="$list[productId]" type="text" value="$list[cartCount]" name="pCount" id='pCount_$list[productId]' class="in_text_cla1" style="width: 30px; height:16px; line-height:16px; text-align: center; float:left" maxlength="4" />
							<a id="add" key=$key productId="$list[productId]" href="#1" style="display:block; margin-top:5px; float:left;width:10px; height:10px; line-height:10px; border:1px solid #DBDBDB">+</a>							</td>
							<td align="center" style="width: 6%; padding-left:5px;"><a id="del" productId="$list[productId]" href="#1">删除</a></td>
						</tr>
						<!--{/loop}-->
						<!--{if $pArr[cartCount]==0}-->
						<tr id="tr_$list[productId]" class="td_b_on">
							<td colspan="8" style="width: 13%; line-height: 15px; color: #ff0000; padding-left: 8px;">你的购物车中还没有信息!</td>
						</tr>
						<!--{/if}-->
					</tbody>
				</table>
			</div>
			<!--{if $pArr[cartCount]>0}-->
			<div class="t_nav" style="margin:0px;">
				


				
				<div class="" style="float:right; ">
					<div class="">
						<div class="" style="font-size:12px">
						<input name="按钮" type="button" id="clearShopping"  value="清空购物车" />
							商品总价(不含运费)：<em id="J_Total" style=" font-family:Verdana, Arial, Helvetica, sans-serif;font-size:18px; color:#FE6500">￥{$pArr[totalPrice]}</em>元
						</div>
					</div>
				</div>
				
			</div>
			
			
			<div class="t_nav" style="clear:both; margin:0px;">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td width="63%"></td>
						<td width="37%" align="right" style="text-align:right">
						<div class="button_1_cla1" style="margin:0px; float:right">
							<div class="button_r_cla1">
								<div class="button_m_cla1">
									<span id="" class="button_shop"><input type="submit" class="submit" value="去结算中心" /></span>
								</div>
							</div>
						</div>
						
						<div class="button_1_cla2" style="float:right">
							<div class="button_r_cla2">
								<div class="button_m_cla2">
									<a id="intoShopping" href="product-list.htm">继续购物</a>
								</div>
							</div>
						</div>						
					  </td>
					</tr>
			  </table>
			</div>
			
			
			<!--{/if}-->
			</form>
		</div>
	</div>
</div>
{template footer}